#---
# Excerpted from "Rails for PHP Developers",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material, 
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose. 
# Visit http://www.pragmaticprogrammer.com/titles/ndphpr for more book information.
#---

class Meeting < ActiveRecord::Base
  has_many :presentations


  validates_presence_of :meets_on
  validates_length_of   :location, :minimum => 4

  # class methods
  def self.upcoming_meetings
    find(:all, :conditions => "meets_on > CURRENT_TIMESTAMP()", 
               :order      => "meets_on")
  end

  def self.past_meetings
    find(:all, :conditions => "meets_on <= CURRENT_TIMESTAMP()", 
               :order      => "meets_on")
  end

  # formatted name based on date
  def name
    meets_on.to_s(:long)
  end

  
  # comma separated list of presentations
  def presentation_list
  end
  
end
